* Table 9
local table "Table9"
use "./data/academics.dta", clear
createvarsacad
keep if tenure
qui putexcel set "./tables/tables.xlsx", sheet("`table'") modify
qui putexcel A2=("Assistant")
qui putexcel A3=("Associate")
qui putexcel A4=("Full")
qui putexcel A5=("Total")
qui putexcel B1=("2001")
qui putexcel C1=("2009")
qui putexcel D1=("2018")
count if year==2001
local tot2001=r(N)
qui putexcel B5=(`tot2001')
count if year==2009
local tot2009=r(N)
qui putexcel C5=(`tot2009')
count if year==2018
local tot2018=r(N)
qui putexcel D5=(`tot2018')
count if year==2001 & newcat==10  /* PROFESSOR AUXILIAR */
local sh101=r(N)/`tot2001'
qui putexcel B2=(`sh101'), nformat(%#.0)
count if year==2009 & newcat==10 /* PROFESSOR AUXILIAR */
local sh109=r(N)/`tot2009'
qui putexcel C2=(`sh109'), nformat(%#.0)
count if year==2018 & newcat==10 /* PROFESSOR AUXILIAR */
local sh118=r(N)/`tot2018'
qui putexcel D2=(`sh118'), nformat(%#.0)
* Associado
count if year==2001 & newcat==8 /* PROFESSOR ASSOCIADO */
local sh201=r(N)/`tot2001'
qui putexcel B3=(`sh201'), nformat(%#.0)
count if year==2009 & newcat==8 /* PROFESSOR ASSOCIADO */
local sh209=r(N)/`tot2009'
qui putexcel C3=(`sh209'), nformat(%#.0)
count if year==2018 & newcat==8 /* PROFESSOR ASSOCIADO */
local sh218=r(N)/`tot2018'
qui putexcel D3=(`sh218'), nformat(%#.0)
* Catedratico
count if year==2001 & newcat==12 /* PROFESSOR CATEDRATICO */
local sh301=r(N)/`tot2001'
qui putexcel B4=(`sh301'), nformat(%#.0)
count if year==2009 & newcat==12 /* PROFESSOR CATEDRATICO */
local sh309=r(N)/`tot2009'
qui putexcel C4=(`sh309'), nformat(%#.0)
count if year==2018 & newcat==12 /* PROFESSOR CATEDRATICO */
local sh318=r(N)/`tot2018'
qui putexcel D4=(`sh318'), nformat(%#.0)
